package com.original.simuladoresws.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.original.simuladoresws.dao.ComparsionDao;
import com.original.simuladoresws.dao.impl.ComparsionDaoImpl;
import com.original.simuladoresws.entities.TbComparsion;
import com.original.simuladoresws.service.ComparsionService;

@Repository("comparsionService")
public class ComparsionServiceImpl implements ComparsionService {
	ComparsionDao comparsionDao = new ComparsionDaoImpl();
	@Override
	public Integer save(TbComparsion comp) {
		return (Integer) comparsionDao.create(comp);
	}
	
	@Override
	public Integer getId() {
		List<TbComparsion> ls = comparsionDao.lastestObject(TbComparsion.class);
		Integer idReturn = 1;
		if (ls != null && ls.size() > 0) {
			TbComparsion obj = ls.get(ls.size() - 1);
			idReturn = obj.getId()  + 1;
		}
		return idReturn;
	}
}
